Prune real-time branch of deep hierarchical caggs - #10175
Conversation
8776152 to
18649b5
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@Poroma-Banerjee, @natalya-aksman: please review this pull request.
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a performance/planning issue for deep (3+ level) hierarchical real-time continuous aggregates by fully unwrapping nested time_bucket() comparisons into constraints on the underlying raw time column, enabling real-time branch pruning and better chunk exclusion at any nesting depth.
Changes:
- Added
ts_transform_nested_time_bucket_comparison()to repeatedly apply the existing single-leveltime_bucket()comparison transform until no further unwrapping is possible. - Switched hypertable expansion and chunk-append runtime constification to use the nested transform so deep hierarchical caggs get fully reduced constraints.
- Added a regression test (+ expected output) validating that the real-time branch is pruned (“One-Time Filter: false”) for 3- and 4-level hierarchical real-time caggs.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
tsl/test/sql/CMakeLists.txt |
Registers the new hierarchical real-time cagg regression test. |
tsl/test/sql/cagg_hierarchical_realtime.sql |
New regression test reproducing #10071 and validating pruning for 2/3/4 levels. |
tsl/test/expected/cagg_hierarchical_realtime.out |
Expected EXPLAIN plans showing real-time branch pruning at deeper nesting. |
src/planner/planner.h |
Exposes the new nested transform helper. |
src/planner/expand_hypertable.c |
Implements nested transform and uses it in qual processing / timebucket annotation / simplified restrictions. |
src/nodes/chunk_append/exec.c |
Uses nested transform during runtime constification to improve chunk exclusion with nested buckets. |
.unreleased/fix_10071 |
Adds release note entry for the fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c790eff to
5f4cd4b
Compare
A single application of ts_transform_time_bucket_comparison() strips only the outermost time_bucket() from a comparison. In a hierarchical continuous aggregate the bucket input is itself another time_bucket() call. The real-time branch could not be proven empty and the refresh re-scanned the whole raw un-materialized tail of the base hypertable. Add ts_transform_nested_time_bucket_comparison(), which applies the single-level transform repeatedly until the bound is expressed on the raw column. Only the original qual and the fully reduced qual are kept; the intermediate levels have no consumer. Fixes: timescale#10071
|
Automated backport to 2.28.x not done: cherry-pick failed. Git status |
A single application of ts_transform_time_bucket_comparison() strips only the outermost time_bucket() from a comparison. In a hierarchical continuous aggregate the bucket input is itself another time_bucket() call. The real-time branch could not be proven empty and the refresh re-scanned the whole raw un-materialized tail of the base hypertable. Add ts_transform_nested_time_bucket_comparison(), which applies the single-level transform repeatedly until the bound is expressed on the raw column. Only the original qual and the fully reduced qual are kept; the intermediate levels have no consumer. Fixes: #10071 (cherry picked from commit 5ebc0fa)
A single application of ts_transform_time_bucket_comparison() strips
only the outermost time_bucket() from a comparison. In a hierarchical
continuous aggregate the bucket input is itself another time_bucket()
call. The real-time branch could not be proven empty and the refresh
re-scanned the whole raw un-materialized tail of the base hypertable.
Add ts_transform_nested_time_bucket_comparison(), which applies the
single-level transform repeatedly until the bound is expressed on the
raw column. Only the original qual and the fully reduced qual are kept;
the intermediate levels have no consumer.
Fixes: #10071